package com.aaa.controller;

import com.aaa.config.NonStaticResourceHttpRequestHandler;
import com.aaa.entity.Video;
import com.aaa.service.impl.VideoServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
//import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import javax.annotation.Resource;
import java.awt.print.Book;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;

/**
 * @ClassName: VideoController
 * @Description: TODO
 * @Author: 86139
 * @Date: 2021/9/12 22:02
 * @Version:1.0
 **/
@RestController
@RequestMapping("video")
@AllArgsConstructor
public class VideoController {
    private final NonStaticResourceHttpRequestHandler nonStaticResourceHttpRequestHandler;
    @Resource
    VideoServiceImpl videoService;
    @RequestMapping("finAll")
    public PageInfo finAll(Integer pageNum, Integer pageSize,String value){
        PageHelper.startPage(pageNum,pageSize);

        QueryWrapper<Video> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("audit_state",0);
        List<Video> list = videoService.list(queryWrapper);
        PageInfo<Video> rolePageInfo = new PageInfo<Video>(list);
        return rolePageInfo;
    }
    @RequestMapping("videoRecord")
    public PageInfo videoRecord(Integer pageNum, Integer pageSize,String value){
        PageHelper.startPage(pageNum,pageSize);
        if(value.equals("0")||value==""||value==null){
            QueryWrapper<Video> queryWrapper = new QueryWrapper<>();
            queryWrapper.ne("audit_state",0);
            List<Video> list = videoService.list(queryWrapper);
            PageInfo<Video> rolePageInfo = new PageInfo<Video>(list);
            return rolePageInfo;
        }
        QueryWrapper<Video> queryWrapper = new QueryWrapper<>();
        queryWrapper.ne("audit_state",0);
        queryWrapper.eq("auditor",value);
        List<Video> list = videoService.list(queryWrapper);
        PageInfo<Video> rolePageInfo = new PageInfo<Video>(list);
        return rolePageInfo;

    }
    @RequestMapping("updateState")
    public boolean updateState(Video video){
        System.out.println(video);
        return videoService.updateById(video);
    }
}
